package dao;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import util.HibernateUtil;

import modelo.Estadocita;


public class EstadocitaDao implements Serializable{

	private static final long serialVersionUID = 8793637914751841187L;
	private Session session;
	SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
	
	public EstadocitaDao() {
		super();
	}

	public EstadocitaDao(Session session, SessionFactory sessionFactory) {
		super();
		this.session = session;
	}

	public List<Estadocita> obtener() {
		session=sessionFactory.openSession();
		
		Query query = session.createQuery("SELECT ec FROM Estadocita ec");
		List<Estadocita> ec = query.list();
		
		session.close();
		
		return ec;
	}
	
	public Estadocita obtenerEstadocitaById(int id){
		session=sessionFactory.openSession();
		Query query = session.createQuery("from Estadocita where Id = :id ");
        query.setParameter("id", id);

        List<?> list = query.list();

        Estadocita ec = (Estadocita)list.get(0);
        return ec;
	}
	
/*	public void guardarComboBebida(ComboBebida cb){
		session=sessionFactory.openSession();
		session.beginTransaction();
		session.saveOrUpdate(cb);
		session.getTransaction().commit();
		session.close();
	}
*/
/*	public void eliminarComboBebida(ComboBebida cb) {
		session=sessionFactory.openSession();
		session.beginTransaction();
		session.delete(cb);
		session.getTransaction().commit();
		session.close();
	}
*/
}